<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
	
<style type="text/css">

.ui-datatable-scrollable-header-box {
    margin-left: 0px;
    margin-right: 15px !important;
}

</style>

	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<!-- <ui:include src="problemBaseDialog.xhtml" /> -->
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="headForm">
				<div class="box-header" id="queryDiv">
					<p:outputLabel value="创建时间：" style="margin-left:5px;" />
					<p:calendar id="popup1" navigator="true" size="15" value="#{problemBaseControlller.queryDateStart}"
						pattern="yyyy-MM-dd" maxdate="Date()" />
					<p:outputLabel for="popup2" value="至 " style="margin-right:5px;margin-left:5px;" />
					<p:calendar id="popup2" navigator="true" size="15" value="#{problemBaseControlller.queryDateEnd}"
						pattern="yyyy-MM-dd" maxdate="Date()">
					</p:calendar>
					<p:commandButton value="查询" actionListener="#{problemBaseControlller.query}" oncomplete="closeSelectDiv();"
						update="form:dataTb" icon="ui-icon-search" style="margin-left:5px;">
					</p:commandButton>
					<p:commandButton icon="ui-icon-refresh" value="重置" oncomplete="closeSelectDiv();"
						actionListener="#{problemBaseControlller.resetQuery}" style="margin-left:5px;" 
						update="popup1 popup2 btnBar :form:dataTb creater problemClass description source dangerLevel reasonClass"  />
					<div class="box-tools pull-right">
						<button type="button" id="selectButton" title="高级查询" class="btn btn-default"
							onclick="onSelectDivClick();" style="margin-right: 50px;">
							<span id="selectButtonIcon" class="fa fa-caret-down">高级查询</span>
						</button>
					</div>
				</div>
				<div class="panel-collapse collapse" id="selectDiv">
					<div style="margin-top:10px;margin-bottom:5px;">
						<p:outputLabel value="创建人员：" style="margin-left:15px;" />
						<p:autoComplete dropdown="true" scrollHeight="400" id="creater"
							value="#{problemBaseControlller.expertId}"
							var="expert" itemLabel="#{expert.name}" itemValue="#{expert.id}"
							completeMethod="#{expertController.completeExpert}" >
						</p:autoComplete>
						
						<p:outputLabel value="问题分类：" style="margin-left:15px;" />
						<p:autoComplete value="#{problemBaseControlller.queryProblem.problemClass}" id="problemClass"
				        	completeMethod="#{knowledgeBaseController.completeHiddenDangerQuesClass}" 
				    	    scrollHeight="400" dropdown="true" />
						
						<p:outputLabel value="问题描述：" style="margin-left:15px;" />
						<p:inputText value="#{problemBaseControlller.queryProblem.problemDescription}" id="description"/>
					</div>
					<div style="margin-top:5px;margin-bottom:5px;">
						<p:outputLabel value="问题来源：" style="margin-left:15px;" />
						<p:autoComplete value="#{problemBaseControlller.queryProblem.problemSources}" id="source"
							completeMethod="#{knowledgeBaseController.completeHiddenDangerSources}"
							scrollHeight="400" dropdown="true" />
						
						<p:outputLabel value="严重等级：" style="margin-left:15px;" />
						<p:autoComplete value="#{problemBaseControlller.queryProblem.problemDangerLevel}" id="dangerLevel"
					    	completeMethod="#{knowledgeBaseController.completeHiddenDangerGrade}" 
					    	scrollHeight="400" dropdown="true" />
					    	
						<p:outputLabel value="原因分类：" style="margin-left:15px;" />
						<p:autoComplete value="#{problemBaseControlller.queryProblem.problemReasonClass}" id="reasonClass"
				        	completeMethod="#{knowledgeBaseController.completeHiddenDangerReasonClass}" 
				    	    scrollHeight="400" dropdown="true" />
					</div>
				</div>
				
				<div id="toolbarDiv">
					<p:toolbar id="btnBar">
						<f:facet name="left">
							<p:commandButton value="新建" id="createBtn"
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_jcsjzd_wtk_xj')}"
								oncomplete="PF('editDlg').show()" actionListener="#{problemBaseControlller.preCreate()}"
								update="editForm:editDlg " icon="fa fa-plus" />
							<p:commandButton value="编辑" id="editBtn"
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_jcsjzd_wtk_bj')}"
								disabled="#{problemBaseControlller.selected==null}"
								oncomplete="PF('editDlg').show()" actionListener="#{problemBaseControlller.preEdit()}"
								update="editForm:editDlg" icon="fa fa-pencil" />
							<p:commandButton value="删除" id="delBtn"
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_jcsjzd_wtk_sc')}"
								disabled="#{problemBaseControlller.selected==null}"
								actionListener="#{problemBaseControlller.delete}"
								oncomplete="getTableScrollHeight();" icon="fa fa-trash"
								update="form:msgs form:dataTb delBtn editBtn">
								<p:confirm header="提示" message="确定要删除么？" icon="ui-icon-alert" />
							</p:commandButton>
						</f:facet>
					</p:toolbar>
				</div>
			</h:form>
		</div>
		<div id="infoDiv" class="box box-solid with-border">
			<h:form id="form">
				<p:growl id="msgs" showDetail="true" />
				<p:dataTable id="dataTb" var="item" emptyMessage="无记录" rowIndexVar="ite" lazy="true"
					value="#{problemBaseControlller.problems}" rowKey="#{item.id}" rows="20" paginator="true"
					selection="#{problemBaseControlller.selected}" 
					paginatorTemplate="{left} {RowsPerPageDropdown} {right} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Customer}"
					rowsPerPageTemplate="20,30,50" paginatorPosition="bottom" scrollable="true" >
					<p:ajax event="rowSelectRadio" update="headForm:btnBar" listener="#{problemBaseControlller.onRowSelected}" />
					<f:facet name="{Customer}">
             			<p:outputLabel value="总计：#{problemBaseControlller.problems.size()}条纪录" style="margin-left:20px" />
             		</f:facet>
					<f:facet name="{left}">
             			<p:outputLabel value="每页显示" />
             		</f:facet>
					<f:facet name="{right}">
             			<p:outputLabel value="条" style="margin-right:20px"/>
             		</f:facet>
             		<p:column selectionMode="single" style="text-align:center;" width="2"/>
					<p:column headerText="序号" style="text-align:center;" width="4">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="问题描述" width="38" >
						<h:outputText value="#{item.problemDescription}" />
					</p:column>
					<p:column headerText="问题分类" style="text-align:center;" width="10">
						<h:outputText value="#{item.problemClass}" />
					</p:column>
					<p:column headerText="原因" style="text-align:center;" width="10">
						<h:outputText value="#{item.problemReasonClass}" />
					</p:column>
					<p:column headerText="严重等级" style="text-align:center;" width="8">
						<h:outputText value="#{item.problemDangerLevel}" />
					</p:column>
					<p:column headerText="问题来源" style="text-align:center;" width="8">
						<h:outputText value="#{item.problemSources}" />
					</p:column>
					<p:column headerText="创建时间" style="text-align:center;" width="10">
						<h:outputText value="#{item.createTime}">
							<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" />
						</h:outputText>
					</p:column>
					<p:column headerText="创建人员" style="text-align:center;" width="10">  
						<h:outputText value="#{item.createrName}" />
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="editForm">
				<p:dialog widgetVar="editDlg" modal="true" id="editDlg" width="800" height="500"
					header="#{problemBaseControlller.selected.id != null ? '编辑':'新建'}" >
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" style="float: right;" icon="fa fa-floppy-o"
								update=":form:dataTb :form:msgs :headForm:delBtn :headForm:editBtn"
								actionListener="#{problemBaseControlller.save()}" oncomplete="afterCreate();" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel style="width:100%;">
						<p:panelGrid style="width:100%">
							<p:row>							
								<p:column>
									<h:outputText value="问题归类:" />
								</p:column>
								<p:column>
								     <p:autoComplete value="#{problemBaseControlller.current.problemClass}"
							        	completeMethod="#{knowledgeBaseController.completeHiddenDangerQuesClass}" 
							    	    scrollHeight="400" dropdown="true" />
								</p:column>
								<p:column>
									<h:outputText value="原因归类:" />
								</p:column>
								<p:column>
								 	<p:autoComplete  value="#{problemBaseControlller.current.problemReasonClass}"
							        	completeMethod="#{knowledgeBaseController.completeHiddenDangerReasonClass}" 
							    	    scrollHeight="400" dropdown="true" />
								</p:column>
							</p:row>
							<p:row>							
								<p:column>
									<h:outputText value="严重等级:" />
								</p:column>
								<p:column>
								    <p:autoComplete  value="#{problemBaseControlller.current.problemDangerLevel}"
								    	completeMethod="#{knowledgeBaseController.completeHiddenDangerGrade}" 
								    	scrollHeight="400" dropdown="true" />
								</p:column>
								<p:column>
									<h:outputText value="问题来源：" />
								</p:column>
								<p:column>
								      <p:autoComplete  value="#{problemBaseControlller.current.problemSources}"
									      completeMethod="#{knowledgeBaseController.completeHiddenDangerSources}"
									      scrollHeight="400" dropdown="true" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputText value="问题描述:" />
								</p:column>
								<p:column colspan="5">
									<h:inputTextarea rows="6" label="content" autoResize="false"
										value="#{problemBaseControlller.current.problemDescription}" style="width:100%;" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputText value="创建人员:" />
								</p:column>
								<p:column>
									<p:inputText label="content" required="true" readonly="true"
										value="#{problemBaseControlller.current.createrName}" />
								</p:column>
								<p:column>
									<h:outputText value="创建时间:" />
								</p:column>
								<p:column>
									<p:calendar value="#{problemBaseControlller.current.createTime}" navigator="true"
										pattern="yyyy-MM-dd HH:mm:ss" showHour="true" showMinute="true" showSecond="true" />
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script type="text/javascript" src="/resources/js/mymodal.js" />
		<script src="/resources/js/tables/singleScrollTable.js"/>
		<script>
			function afterCreate() {
				PF('editDlg').hide();
				getTableScrollHeight();
			}
		</script>
	</ui:define>
</ui:composition>